/*
 * @(#)Classes.java        0.1 09/04/29
 * @version 	0.1 29 Apr 2009
 * @author 	Tran Dai Hiep
 * 
 * Quan ly cac Class
 */


package Data;

import java.util.*;


public class Classes {
	private static Classes instance = new Classes();
	public static Classes getInstance() {
		return instance;
	}
	protected Classes() {
		classes = new LinkedList<Class>();
	}
	
	private LinkedList<Class> classes;
	
	public void addClass(Class c) {
		classes.addLast(c);
	}
	
	/*
	 * Tim 1 class
	 * @param id: id cua class can tim
	 */
	public Class getClass(long id) {
		int size = classes.size();
		for (int i = 0; i < size; i++) {
			if (classes.get(i).getId() == id) return classes.get(i);
		}
		return null;
	}
	
	/*
	 * Lay thong tin cua tat ca cac class
	 */
	public LinkedList<Class> getClasses() {
		return classes;
	}
	
	/*
	 * Quan ly nhom cac class moi
	 */
	public void setClasses(LinkedList<Class> c) {
		classes = new LinkedList<Class>(c);
	}
	
	/*
	 * Xoa mot class
	 */
	public void removeClass(Class c) {
		classes.remove(c);
	}
	
	public int size() {
		return classes.size();
	}

	public void reset() {
		classes = new LinkedList<Class>();
		Class.reset();
	}
	
	
}
